// 电压读取演示代码

#include <cupeVoltage.h>

void CupeVoltage::init()
{
  pinMode(PWR_VOL, INPUT_PULLUP);
  pinMode(BAT_VOL, INPUT_PULLUP);
}

void CupeVoltage::loop()
{
  uint16_t voltage;

  analogRead(PWR_VOL);
  voltage = 0;
  for (int i = 0; i < 10; i++)
  {
    voltage += analogRead(PWR_VOL);
  }
  dbLog("\nPower Voltage = %d", (voltage << 1) / 31);

  analogRead(BAT_VOL);
  voltage = 0;
  for (int i = 0; i < 10; i++)
  {
    delay(10);
    voltage += analogRead(BAT_VOL);
  }
  dbLog("\nBattery Voltage %d", (voltage << 1) / 31);

  delay(1000);
}

